<%@page import="java.util.Calendar"%>
<%@page import="java.util.Date"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
//Date date=new Date();
//out.print(date);
Calendar ca = Calendar.getInstance();//创建一个日期实例
//输出  XXXX年XX月XX日
out.println(ca.get(Calendar.YEAR)+"年"+(ca.get(Calendar.MONTH)+1)+"月"+ca.get(Calendar.DATE)+"日");
//用Calendar实现  判断是否是闰年    能够被4整除但不能被100整除，或者能够被400整除
 if( ca.get(Calendar.YEAR)%4==0&&ca.get(Calendar.YEAR)%100!=0 || ca.get(Calendar.YEAR)%400==0) {
	 out.println(ca.get(Calendar.YEAR)+"年是闰年");
			switch (ca.get(Calendar.MONTH)+1) {
			case 1:case 3:case 5:case 7:case 8:case 10:case 12:
				out.println((ca.get(Calendar.MONTH)+1)+"月共"+31+"天");
				break;
			case 2:
				out.println((ca.get(Calendar.MONTH)+1)+"月共"+29+"天");				
				break;
			case 4:case 6:case 9:case 11:
				out.println((ca.get(Calendar.MONTH)+1)+"月共"+30+"天");		
				break;
			default:
				break;
			}
		}
		else{
			out.println(ca.get(Calendar.YEAR)+"年不是闰年");
			switch (ca.get(Calendar.MONTH)+1) {
			case 1:case 3:case 5:case 7:case 8:case 10:case 12:
				out.println((ca.get(Calendar.MONTH)+1)+"月共"+31+"天");
				break;
			case 2:
				out.println((ca.get(Calendar.MONTH)+1)+"月共"+28+"天");				
				break;
			case 4:case 6:case 9:case 11:
				out.println((ca.get(Calendar.MONTH)+1)+"月共"+30+"天");		
				break;
			default:
				break;
			}
		}

%>
</body>
</html>